<template>
    <!-- 头部部分 -->
  <header class="header">
    <h1>todos</h1>
    <input @keydown.enter="addtask" v-model="task" class="new-todo" placeholder="请输入任务名称" autofocus />
  </header>
</template>

<script>
export default {
  name: 'SrcTodosMyHeader',

  data() {
    return {
      task: '' ,
    };
  },

  mounted() {
    
  },

  methods: {
    addtask(){
          if(!this.task.trim()) {
         alert('task 为空')
            return
          }
        this.$store.commit('add',{
         id:Date.now(),
         name:this.task.trim(),
         isDone:false
        })
        
        this.task = ''
        }
  },

  
};
</script>